<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>title</title>
	<link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<style type="text/css">
		.aui-border-input-radius {
			border-radius: 20px;
		}
	</style>
</head>

<body>
	<!-- 顶部搜索框 -->
	<section class="aui-bg-tag-money">
		<header class="aui-bar aui-bar-nav" id="aui-header">
			<a class="aui-pull-left aui-btn" tapmode onclick="api.closeWin();">
				<span class="aui-iconfont aui-icon-left"></span>
			</a>
			<div class="aui-title" style="left:2rem; right: 2rem;">
				<div class="aui-searchbar">
					<div class="aui-searchbar-input aui-border-radius aui-border-input-radius">
						<i class="aui-iconfont aui-icon-search"></i>
						<input type="search" placeholder="请输入搜索内容" id="search-input" class="searchword">
					</div>

				</div>
			</div>
			<a class="aui-pull-right">
				<span class="aui-iconfont aui-font-size-14 dosearch">搜索</span>
			</a>
		</header>
		<div style="height:45px;"></div>
	</section>
	<!--商品列表-->
	<div class="goodslist aui-margin-t-5 aui-padded-5" id="div_goods_list">
	</div>
</body>

</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script>
	var pageParam;
	var userinfo, header;
	apiready = function() {
		initPage();
		doSeaarch();
	}

	function initPage() {
		header = $api.byId('aui-header');
		$api.fixStatusBar(header);
		setNavMenu('search', $api.offset(header).h, Gtablist, {
			width: api.winWidth / 5
		});
		pageParam = api.pageParam;
		if (pageParam.data) {
			pageParam = pageParam.data;
		}
		if (!pageParam.keyword) {
			pageParam.keyword = $api.getStorage('appSetInfo').keyword || '女装';
		}
		if (!pageParam.source_type) {
			pageParam.source_type = $api.getStorage('appSetInfo').indexshowtype;
		}
		$('.searchword').val(pageParam.keyword);
		var frame_list = new Array;
		for (var i = 0; i < Gtablist.length; i++) {
			frame_list[i] = {
				name: 'search_frame_' + i,
				url: './index_frames.html',
				pageParam: {
					source_type: Gtablist[i].value,
					keyword: pageParam.keyword,
					apiname: Gtablist[i].value == 'vip' ? 'goodsearch' : 'goodslist'
				},
				bounces: true,
				allowEdit: true,
				useWKWebView: true,
			}
		}

		api.openFrameGroup({
			name: 'search_frame_list',
			scrollEnabled: true,
			rect: {
				marginLeft: 0,
				marginRight: 0,
				marginTop: $api.offset(header).h + 45,
				marginBottom: 0
			},
			fixedOn: 'ui_layout',
			index: 0,
			preload: 2,
			frames: frame_list
		}, function(ret, err) {
			pageParam.searchIndex = ret.index;
			setNavMenuSelected('search', ret.index);
		});
	}

	function doSeaarch() {
		$('.dosearch').click(function() {
			doSearchKeyword();
		});
		$(".searchword").keydown(function(e) {
			if (e.keyCode == 13) {
				doSearchKeyword();
			}
		});
	}

	function doSearchKeyword() {
		sorts_data.keyword = $('.searchword').val();
		api.setFrameGroupIndex({
			name: 'search_frame_list',
			index: pageParam.searchIndex,
			scroll: true
		});
		for (var i in Gtablist) {
			api.execScript({
				frameName: 'search_frame_' + i,
				script: "doSearchKeyword('" + sorts_data.keyword + "');"
			});
		}
	}
</script>
